#代码来自:https://blog.csdn.net/weixin_39595621/article/details/110579269
import cv2  
import numpy as np
 
 
image = cv2.imread("exami.png")
cv2.namedWindow("input image", cv2.WINDOW_AUTOSIZE)
cv2.imshow("input image", image)
 
#均值模糊
dst = cv2.blur(image, (5, 5))
cv2.imshow("blur_demo", dst)
 
#中值模糊
dst = cv2.medianBlur(image, 5)
cv2.imshow("median_blur_demo", dst)
 
#自定义模糊
#kernel = np.ones([5, 5], np.float32)/25
kernel = np.array([[0, -1, 0],[-1, 5, -1],[0, -1, 0]], np.float32)
dst = cv2.filter2D(image, -1, kernel=kernel)
cv2.imshow("custom_blur_demo", dst)
cv2.imwrite("out.png", dst) 
 
cv2.waitKey(0)
cv2.destroyAllWindows()